# -*- coding: utf-8 -*-
"""
Created on Fri Sep  6 22:28:19 2024

@author: Hasee
"""
import pygame
import plane_sprites

pygame.init()
clock = pygame.time.Clock()

screen = pygame.display.set_mode((480,700))

#背景
bg = pygame.image.load("./images/background.png")
screen.blit(bg,(0,0))
    
#我的飞机
my = pygame.image.load("./images/me1.png")
my_size = pygame.Rect(150,300,102,126)

#敌机的精灵
Enemy = plane_sprites.GameSprite("./images/enemy1.png")
#敌机的精灵组
Enemy_group = pygame.sprite.Group(Enemy)


while True:
    
    event_list = pygame.event.get()
    if len(event_list) > 0:
        print(event_list)
        for event in event_list:
        
        	# 判断用户是否点击了关闭按钮
            if event.type == pygame.QUIT:
        		# quit卸载所有模块
                pygame.quit()
                exit()
                
    clock.tick(60)
    
    my_size.y-=5
    if my_size.y<=-126:
        my_size.y = 700
        
    screen.blit(bg,(0,0))
    screen.blit(my,my_size)
        
    #敌机
    Enemy_group.update()
    Enemy_group.draw(screen)
    

    pygame.display.update()     
    
    
    
    
